import { BaseDataListPanel } from "./BaseDataListPanel";
import { Language } from "../../../../extend/language/Language";
import { GuildRender } from "./GuildRender";
import { Cache } from "../../cache/Cache";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { GuildController } from "../../control/GuildController";
import { GuildShowType } from "./GuildShowType";
import { GTextInput } from "../../../../com/mui/controls/GTextInput";
import { GameConst } from "../../../component/gconst/GameConst";
import { GButton } from "../../../../com/mui/controls/GButton";
import { DataEvent } from "../../events/DataEvent";
import { GuildEventName } from "./GuildEventName";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { EventName } from "../../mvc/EventName";
import { _startIndex } from "../../../../this/_startIndex";
type int = number;
//class GuildListPanel
    
    export  class GuildListPanel extends BaseDataListPanel
    {
        constructor()
        {
            super(titleColumn);
            titleColumn = Language.getArray(57021, "x");
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            tileList.setStyle("cellRenderer", GuildRender);
            tileList.setSize(520, 300);
            bgWidth = 520;
            if (Cache.instance.guild.myGuildInfo) 
            {
                ObjCreate.createTextField(Language.getString(57022), 20, 380, 100, 20, this, GlobalStyle.textFormat6);
                this._rankTxt = ObjCreate.createTextField("", 90, 380, 100, 20, this, GlobalStyle.textFormat6);
                this._rankTxt.addEventListener(flash.events.TextEvent.LINK, this.onRankClickHandler);
            }
            if (GuildController.curShowType == GuildShowType.MyGuildList) 
            {
                ObjCreate.createTextField(Language.getString(57023), 410, 380, 100, 20, this, GlobalStyle.textFormat2);
                this._nameInput = new GTextInput();
                this._nameInput.maxChars = GameConst.GuildNameLimit;
                this._nameInput.styleName = "GTextInput";
                this._nameInput.name = "searchName";
                this._nameInput.width = 100;
                this._nameInput.x = 480;
                this._nameInput.y = 378;
                this.addChild(this._nameInput);
                this._searchBtn = new GButton();
                this._searchBtn.styleName = "Button";
                this._searchBtn.label = Language.getString(57024);
                this._searchBtn.setSize(60, 24);
                this._searchBtn.move(585, 377);
                this._searchBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onSearchBtnClickHandler);
                this.addChild(this._searchBtn);
            }
            return;
        }

        public updateRank(arg1: int): void
        {
            if (this._rankTxt) 
            {
                this._rankTxt.htmlText = "<a href=\'event: 0\'><u>" + arg1 + "</u></a>";
            }
            return;
        }

        public get tileWidth(): int
        {
            return this._tileWidth;
        }

        public set tileWidth(arg1: int)
        {
            this._tileWidth = arg1;
            tileList.setSize(arg1, 300);
            return;
        }

        /* internal  */onRankClickHandler(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc1=Cache.instance.guild.getMyGuildPageIndex();
            this.dispatchEvent(new DataEvent(GuildEventName.GuildToPage, loc1, false, true));
            return;
        }

        /* internal  */onSearchBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=this._nameInput.text;
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildSearch, {"camp": 0, "guildName": loc1, "startIndex": _startIndex, "isFull": false}));
            return;
        }

        public doSearch(arg1: int): void
        {
            this._startIndex = arg1;
            this.onSearchBtnClickHandler(null);
            return;
        }

        public setNameTxt(arg1: string): void
        {
            this._nameInput.text = arg1;
            return;
        }

        /* internal */ /* var */_rankTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_tileWidth: int;

        /* internal */ /* var */_nameInput: GTextInput;

        /* internal */ /* var */_searchBtn: GButton;

        /* internal */ /* var */_startIndex: int;
    }
